'    Copyright 2008 Jan Molnar <jan.molnar@abds.de>
'
'    This file is part of JCQ.

'    JCQ is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 2 of the License, or
'    (at your option) any later version.

'    JCQ is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.

'    You should have received a copy of the GNU General Public License
'    along with JCQ. If not, see <http://www.gnu.org/licenses/>.

Imports System.Xml

''' <summary>
''' Provides serialization functionality.
''' </summary>
Public Interface ISerializer
    ''' <summary>
    ''' Gets a unique Id for a specified object graph.
    ''' </summary>
    ''' <remarks>This Id is used as a reference value which needs fixup.</remarks>
    Function GetSerializeObjectId(ByVal graph As Object) As Integer

    ''' <summary>
    ''' Gets an object represented by a specified Id.
    ''' </summary>
    Function GetDeserializeObjectById(ByVal id As Integer) As Object

    ''' <summary>
    ''' Serializes the complete object graph into a specified XmlWriter.
    ''' </summary>
    Sub Serialize(ByVal graph As Object, ByVal writer As XmlWriter)

    ''' <summary>
    ''' Deserializes an object from a specified XmlReader.
    ''' </summary>
    Function Deserialize(ByVal reader As XmlReader) As Object

    'Sub RegisterCompletionCall(ByVal callback As Action(Of ISerializer))

    ''' <summary>
    ''' Registers a specified IValueFormatter for a specified value type.
    ''' </summary>
    Sub RegisterValueFormatter(ByVal type As Type, ByVal formatter As IValueFormatter)

    ''' <summary>
    ''' Registers a specified IReferenceFormatter for a specified reference type.
    ''' </summary>
    Sub RegisterReferenceFormatter(ByVal type As Type, ByVal formatter As IReferenceFormatter)

    ''' <summary>
    ''' Gets a IValueFormatter for a specified type. 
    ''' </summary>
    Function GetValueFormatter(ByVal type As Type) As IValueFormatter

    ''' <summary>
    ''' Gets a IReferenceFormatter for a specified type. 
    ''' </summary>
    Function GetReferenceFormatter(ByVal type As Type) As IReferenceFormatter

    ''' <summary>
    ''' Registers an deserialized object.
    ''' </summary>
    Sub RegisterObject(ByVal id As Integer, ByVal graph As Object)

    ''' <summary>
    ''' Registers a PropertyValueFixUp.
    ''' </summary>
    ''' <remarks>Register a PropertyValueFixUp during the deserialization process
    ''' to allow property value fixup. This is used for properties which represent reference types
    ''' which may not be available while deserializing the host.</remarks>
    Sub RegisterPropertyValueFixUp(ByVal fixup As PropertyValueFixUp)

    ''' <summary>
    ''' Registers a ListItemFixUp.
    ''' </summary>
    ''' <remarks>Register a ListItemFixUp during the deserialization process
    ''' to allow list item fixup. This is used for lists which contain reference type objects
    ''' which may not be available while deserializing the list.</remarks>
    Sub RegisterListItemFixUp(ByVal fixup As ListItemFixUp)

    ''' <summary>
    ''' Registers a ReadOnlyListPropertyFixUp.
    ''' </summary>
    ''' <remarks>Register a ReadOnlyListPropertyFixUp during the deserialization process
    ''' to allow readonly list property fixup. This is used for readonly properties of type
    ''' System.Collection.IList. Their data will be deserialized into a temporary list and added
    ''' afterwards.</remarks>
    Sub RegisterReadOnlyListPropertyFixUp(ByVal fixup As ReadOnlyListPropertyFixUp)

    ''' <summary>
    ''' Register a custom IFixUp implementation.
    ''' </summary>
    Sub RegisterCustomFixUp(ByVal fixup As IFixUp)
End Interface

'Public Enum SerializationState
'    Initializing
'    Initialized
'    Parsing
'End Enum